<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');

$browser = new KTDTestFunctional(new sfBrowser());
$browser->loadData();

$browser->info("Aventures")->
        info("I - Authentification, on prepare le terrain (Personnage actuel selectionne)")->
        auth("lambda_member", "lambda_member")->
        setActualCharacterId('2001', "lambda_member");
$browser->
        info("II - Creer une aventure")->
        get("/")->
        info("  II.1 - On va a la region Lambda ")->
        click('.rp-link')->
        click('Lambda Region')->
        
        info("  II.2 - On clique pour poster, et on remplit le formulaire ")->
        click("En route pour l'aventure !")->
        with("request")->begin()->
            isParameter("module", "adventure")->
            isParameter("action", "new")->
        end()->
        click("GO !", array("ktd_adventure" => array("title" => "Aventure Lambda",
                                                     "first_action"=> array("body" => "Lambda FAct")
                                                     )
                            )
             )->

        info("  II.3 - Verification du formulaire")->
        with("form")->begin()->
        hasErrors(0)->
        end()->
        with("response")->
            isRedirected()->
            followRedirect();
$browser->
        info("III - Editer une action")->
        click("Editer")->
        with("request")->begin()->
            isParameter("module", "action")->
            isParameter("action", "edit")->
        end()->
        click("Envoyer", array("ktd_action" => array(
                                    "title" => "Titre Lambda de l'action",
                                    "body" => "Lambda modifie"))
                )->
        with("form")->begin()->
        hasErrors(0)->
        end()->
        with("response")->
            isRedirected()->
            followRedirect();
$browser->
        info("IV - Repondre a une aventure")->
        click("Répondre")->
        with("request")->begin()->
            isParameter("module", "action")->
            isParameter("action", "new")->
        end()->
        click("Envoyer", array("ktd_action" => array(
                                    "title" => "Titre Lambda de l'action",
                                    "body" => "Lambda modifie"))
                )->
        with("form")->begin()->
        hasErrors(0)->
        end()->
        with("response")->
            isRedirected()->
            followRedirect();
$browser->
        info("V - Supprimer une action postee")->
        info("V.1 - La sienne")->
        click("Supprimer", array(), array('position' => 2))->
        with("response")->isRedirected()->followRedirect();



        
?>
